package com.cskaoyan.controller;

import com.cskaoyan.bean.CskaoyanmallBrand;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.WxBrandDetailVoZGY;
import com.cskaoyan.bean.vo.WxBrandsListVo;
import com.cskaoyan.service.WxBrandServiceZGY;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/brand/")
public class WxBrandControllerZGY {

    @Autowired
    WxBrandServiceZGY service;

//    /wx/brand/list?page=1&size=10

    /**
     * 列出品牌：根据传入的page和
     */
    @GetMapping("list")
    public BaseRespVo listBrands(Integer page, Integer size) {

        WxBrandsListVo brandsVo = service.queryBrands(page, size);

        return BaseRespVo.success(brandsVo);
    }

    /**
     * 根据品牌id查询品牌-->微信端显示某品牌的详细信息
     */
    @GetMapping("detail")
    public BaseRespVo getBrandDetail(Integer id){

        CskaoyanmallBrand brand = service.queryBrandDetail(id);

        WxBrandDetailVoZGY wxBrandsVo = new WxBrandDetailVoZGY(brand);

        return BaseRespVo.success(wxBrandsVo);
    }
}
